clear all;close all;
clc;
CHIRP_NUM = 128;
S_NUM = 512;
Tr = 48;
Td = 9.6;
PRT0 = 57.6;
KT = 153.6;
nBins = KT;

fileID = fopen("C:\Users\yf\Desktop\12.bin", 'r');%data14 17_2t4r
data = fread(fileID, 'int16');
data  = reshape(data,CHIRP_NUM*S_NUM,[]);
R1 = data(:,1);R1 = reshape(R1,S_NUM,[]);R1 = R1(1:256,:);
R2 = data(:,2);R2 = reshape(R2,S_NUM,[]);R2 = R2(1:256,:);
R3 = data(:,3);R3 = reshape(R3,S_NUM,[]);R3 = R3(1:256,:);
R4 = data(:,4);R4 = reshape(R4,S_NUM,[]);R4 = R4(1:256,:);
R5 = data(:,5);R5 = reshape(R5,S_NUM,[]);R5 = R5(1:256,:);
% R6 = data(:,6);R6 = reshape(R6,S_NUM,[]);R6 = R6(1:256,:);
% R7 = data(:,7);R7 = reshape(R7,S_NUM,[]);R7 = R7(1:256,:);
% R8 = data(:,8);R8 = reshape(R8,S_NUM,[]);R8 = R8(1:256,:);

% figure(1);
% subplot(441);
% plot(R1);
% subplot(442);
% plot(R2);
% subplot(443);
% plot(R3);
% subplot(444);
% plot(R4);
% subplot(445);
% plot(R5);
% subplot(446);
% plot(R6);
% subplot(447);
% plot(R7);
% subplot(448);
% plot(R8);

avg = mean(R1);
R1 = R1 - avg;

avg = mean(R2);
R2 = R2 - avg;

avg = mean(R3);
R3 = R3 - avg;

avg = mean(R4);
R4 = R4 - avg;


avg = mean(R5);
R5 = R5 - avg;

% 
% avg = mean(R6);
% R6 = R6 - avg;
% 
% avg = mean(R7);
% R7 = R7 - avg;
% 
% avg = mean(R8);
% R8 = R8 - avg;

figure(1);
subplot(441);
plot(R1);
subplot(442);
plot(R2);
subplot(443);
plot(R3);
subplot(444);
plot(R4);
subplot(445);
plot(R5);
% subplot(446);
% plot(R6);
% subplot(447);
% plot(R7);
% subplot(448);
% plot(R8);

